package com.google.code.sysarch.v0.e33;

import com.google.code.sysarch.common.util.Parameter;

//package de.raketenwerfer.java.sysarch.v0;

class v0_33 {

	static int[] buffer = new int[5];
	static int numThreads;

	public static void main(String[] args) {	
		/* Variable initialization */
		if (args.length == 0) {
			System.out.println("Usage: java v0_33 [-n NumberOfThreads] [-m OuterLoopCount] [-t OutputTimeInMs] [-n0..4 InnerLoopCountForThread0..4]");
			System.exit(1);
		}
		Parameter p = new Parameter(args);
		p.warnings = true;
		iThread_33[] threads = new iThread_33[5];
		numThreads = p.getInt("n",1,1,5);
		int innerCycles = p.getInt("m",100,1,500);
		int timeOutput = p.getInt("t",400,1,10000);
		int[] outerCycles = new int[numThreads];
		for (int i = 0; i < numThreads; i++) {
			outerCycles[i] = p.getInt("n"+i, 100, 1, 1000);
		}
		
		/*
		* Create numThreads iThreads and start them, then create one thread fot the output
		*/				
		for (int i = 0; i < numThreads; i++) {
			threads[i] = new iThread_33(outerCycles[i], innerCycles);
		}
		for (int i = 0; i < numThreads; i++) {		
			threads[i].start();
		}

		bosThread_33 boss = new bosThread_33(timeOutput);
		boss.setDaemon(true);		
		boss.start();
	}
	
}